package org.projectwithoutname.ui.menus;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.Widget;

public class PopUpMenu {

	private Menu menu;
	public PopUpMenu(Control control) {
		menu = new Menu(control);
	}
	
	
	/**
	 * create a menu pop up to control object
	 * @param control
	 */
	public void createMenu(Control control) {
		control.setMenu(menu);
	}
	
	/**
	 * Create a menu pop up item of a different types
	 * @param name
	 * @param style
	 */
	public MenuItem createMenuIntem(String name, int style){
		MenuItem item = new MenuItem(menu, style); 
		item.setText(name);
		return item;
	}
	
	/**
	 * Create a sub menu item of a different types
	 * @param name
	 * @param style
	 */
	public MenuItem createMenuIntem(Menu menu, String name, int style){
		MenuItem item = new MenuItem(menu, style); 
		item.setText(name);
		return item;
	}
	
	public void createSubMenu(MenuItem menuItem){
		Menu subMenu = new Menu(menu);
		menuItem.setMenu(subMenu);
	}
	
	/**
	 * create a separator item on menu
	 */
	public void separator(){
		new MenuItem(menu, SWT.SEPARATOR);
	}
	

}
